package com.lcy.controller;


import com.lcy.model.vo.HeatmapDataVo;
import com.lcy.reuslt.Result;
import com.lcy.service.HeatmapService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 热力图控制器
 *
 * @author zhang.rx
 */
@Slf4j
@RestController  // 确保有这个注解
@RequestMapping("/oj/heatmap")  // 路径前缀与其他API一致
@Tag(name = "热力图接口", description = "提供用户提交热力图数据的接口")
public class HeatmapController {

    @Resource
    private HeatmapService heatmapService;

    /**
     * 获取当前用户的提交热力图数据
     */
    @GetMapping("/submission")  // 注意路径格式，确保与前端请求匹配
    @Operation(summary = "获取用户提交热力图", description = "获取当前登录用户的提交热力图数据")
    public Result<List<HeatmapDataVo>> getUserSubmissionHeatmap(
            @Parameter(description = "要获取的天数，默认为55天")
            @RequestParam(required = false) Integer days
    ) {
        log.info("获取用户提交热力图数据，days: {}", days);
        List<HeatmapDataVo> heatmapData = heatmapService.getUserSubmissionHeatmap(days);
        return Result.success(heatmapData);
    }
}